var sym = ['+', '-', 'time10']; // a time10 b  define   => a*10+b
var numList = [1, 2, 3, 4, 5, 6, 7, 8, 9];

for (var p0 = 0; p0 < 3; p0++)
	for (var p1 = 0; p1 < 3; p1++)
		for (var p2 = 0; p2 < 3; p2++)
			for (var p3 = 0; p3 < 3; p3++)
				for (var p4 = 0; p4 < 3; p4++)
					for (var p5 = 0; p5 < 3; p5++)
						for (var p6 = 0; p6 < 3; p6++)
							for (var p7 = 0; p7 < 3; p7++) {

								pStack = [p0, p1, p2, p3, p4, p5, p6, p7]; //一个序列
								opStack = pStack.map(function(item) {
									return sym[item];
								});

								var value = cal(opStack);
								if (value === 100) {
									print(opStack);
								}
							}

// 计算值
function cal(opStack) {
	var nums = numList.map(function(item) {
		return item;
	});
	var ops = opStack.map(function(item) {
		return item;
	});


	// handle * operator
	while (true) {
		var index = ops.indexOf(sym[2]);
		if (index === -1) {
			break;
		}

		var newEle = nums[index] * 10 + nums[index + 1];
		nums.splice(index, 2, newEle);
		ops.splice(index, 1);
	}


	// calculte this series sum
	var value = nums[0];
	for (var i = 1; i <= nums.length - 1; i++) {
		var op = ops[i - 1];
		if (op === '+') {
			value = value + nums[i];
		} else {
			value = value - nums[i];
		}
	}

	return value;
}


function print(opStack) {
	var str = numList[0];
	for (var i = 1; i <= numList.length - 1; i++) {
		var op = opStack[i - 1];
		var opStr = op === sym[2] ? '' : op;
		str += opStr + numList[i];
	}
	console.log(str);
}